<?php

global $_W, $_GPC;
include 'function.php';

$ops = array('list', 'update', 'delete');
$op  = in_array($_GPC['op'], $ops) ? $_GPC['op'] : 'list';

if ($op == 'list') {
    $keywords = safe_gpc_string($_GPC['nickname']);

    $sql   = "SELECT * FROM " . tablename('dgjy_user');
    $where = " WHERE uniacid=:uniacid ";

    //关键字查找
    if (!empty($keywords)) {
        $where = $where . " AND nickname LIKE '%" . $keywords . "%' ";
    }

    $pageIndex  = max(1, intval($_GPC['page']));
    $pageSize   = 10;
    $total      = pdo_fetchcolumn("SELECT count(*) FROM" . tablename('dgjy_user') . $where, array(':uniacid' => $_W['uniacid']));
    $pagination = pagination($total, $pageIndex, $pageSize);
    $user       = pdo_fetchall($sql . $where . " ORDER BY uid DESC LIMIT " . ($pageIndex - 1) * $pageSize . "," . $pageSize, array(':uniacid' => $_W['uniacid']));

    include $this->template('user/user');
}
?>